import React, { useState } from 'react'
import TestState from './components/TestState'
export default function App() {
  let [count, setCount] = useState(100)
  let [msg, setMeg] = useState('react useState')
  console.log('App run')
  return (
    <div>
      <h2>App 组件</h2>
      <p>count :{count}</p>
      <button onClick={() => setCount(count + 1)}>点击</button>
      <p>Msg:{msg}</p>
      <button
        onClick={() => {
          setMeg('react hooks')
        }}
      >
        改变内容
      </button>
      <TestState count={count} msg={msg} />

      {/* 优化 : App 会多运行一次,不像在类组件中,会一直进行渲染 */}
      <button
        onClick={() => {
          setCount(99999)
        }}
      >
        点击固定值
      </button>
    </div>
  )
}
